def check(a):
    
    stack=[]
    o='([{<'
    c=')]}>'
    for i in a:
        if i in o:
            stack.append(i)
        elif i in c:
            z=stack.pop()
            if o.index(z)!=c.index(i):
                    return False
    return len(stack)==0

print(check('(){}[{}]'))
print(check('()[}}('))